/*
 * Description: process preloader
 */

#ifndef PROCESS_PRELOADER_H
#define PROCESS_PRELOADER_H
#include "Windows.h"
#include <chrono>
#include <string>
#include <vector>
#include "performance/perf_constants.h"

namespace PERF {

class ProcessPreloader {
public:
    virtual ~ProcessPreloader() = default;

    virtual void DoPreload() = 0;
    virtual void DoAwaken(const std::string &filepath = "") = 0;
    virtual void Suspend() = 0;
    virtual void Resume() = 0;
    virtual std::string GetProcessName() = 0;

protected:
    int64_t beginTime{ 0 };
    void SuspendProcess(const DWORD pid);
    void ResumeProcess(const DWORD pid);
};

class SingleProcessPreloader : public ProcessPreloader {
public:
    DWORD GetPid();
    void DoPreload() override;
    void DoAwaken(const std::string &filepath) override;
    virtual void Suspend() override;
    virtual void Resume() override;

protected:
    DWORD pid{ 0 };
};

class MultiProcessPreloader : public ProcessPreloader {
public:
    std::vector<DWORD> GetPids();
    void Suspend() override;
    void Resume() override;

protected:
    std::vector<DWORD> pids{};
};

}  // namespace PERF

#endif